#!/bin/sh

######################################
#  BUILDS: Raggle                    #
#    HOME: http://www.raggle.org     #
#  AUTHOR: Lehman Black              #
# CONTACT: bzqwerty[at]gmail[dot]com #
######################################

# Assumed to be public domain per our submission policy
# See the README for dependancies and other configuration information

PRGNAM=raggle
VERSION=0.4.4
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

rm -rf $PKG $TMP/$PRGNAM-$VERSION
mkdir -p $TMP $PKG $OUTPUT

cd $TMP || exit 1
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz || exit 1
cd $PRGNAM-$VERSION || exit 1
chown -R root:root .
chmod -R a-s,u+w,go+r-w .

# Raggle has a bug when running ruby 1.8.4
# Problem goes away with next version of Slackware
patch -p1 < $CWD/raggle_ruby_1.8.4.diff || exit 1

# Some directories need to be changed in the make file
make install PREFIX=$PKG/usr \
	MANDIR=$PKG/usr/man/man1 \
	DOCDIR=$PKG/usr/doc/$PRGNAM-$VERSION

cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

gzip -9 $PKG/usr/man/man1/$PRGNAM.1

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
